package edu.neu.cs6515.board.rules;

import edu.neu.cs6515.board.HexagonBoard;
import edu.neu.cs6515.xml.IngeniousColor;
import edu.neu.cs6515.xml.Placement;

/**
 * Verifies that a placed tile consists of hexagons of one of the 6
 * {@link IngeniousColors}
 */
public final class LegalColorRule extends Rule {

    public static final String REASON = "INVALID-COLOR";

    /**
     * Init class with board obj
     * 
     * @param board
     *            the board to be used for validation
     */
    public LegalColorRule(final HexagonBoard board) {
        super(board);
    }

    @Override
    public boolean validate(final Placement p) {
        final boolean isNull = p.getC0() == null || p.getC1() == null;
        final boolean isWhite = p.getC0() == IngeniousColor.WHITE
                || p.getC1() == IngeniousColor.WHITE;
        return !(isNull || isWhite);
    }

    @Override
    public String getReason() {
        return REASON;
    }
}
